//////////////////////////////////  CRYTEK  ////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2011.
// -------------------------------------------------------------------------
//  File Name        : D3DDebug.h
//  Author           : Vaclav Kyba
//  Time of creation : 11/14/2011
//  Compilers        : VS2010
//  Description      : Control D3D debug runtime output
// -------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////

#ifndef __D3DDEBUG__H__
#define __D3DDEBUG__H__

enum ESeverityCombination
{
	ESeverity_None = 0,
	ESeverity_Info,
	ESeverity_InfoWarning,
	ESeverity_InfoWarningError,
	ESeverity_All
};

#if defined(DIRECT3D10) && !defined(PS3) && !defined(CAFE)

	#define MAX_NUM_DEBUG_MSG_IDS 32

	class CD3DDebug
	{
	public:
		CD3DDebug();
		~CD3DDebug();

		bool Init(ID3D11Device * pD3DDevice);
		void Release();
		void Update(ESeverityCombination muteSeverity, const char * strMuteMsgList, const char * strBreakOnMsgList);

		// To use D3D debug info queue outside of this class,
		// you can push a copy of current settings or empty filter settings onto stack:
		//      m_d3dDebug.GetDebugInfoQueue()->PushCopyOfStorageFilter()  or   PushEmptyStorageFilter()
		//      .... change settings here
		// or push your filter settings directly
		//      m_d3dDebug.GetDebugInfoQueue()->PushStorageFilter(&myFilter);
		// Note that 'PopStorageFilter' should be called before next CD3DDebug::Update,
		// as CD3DDebug::Update modifies filter on top of stack
		ID3D11InfoQueue* GetDebugInfoQueue()
		{
			return m_pd3dDebugQueue;
		}
		ID3D11Debug* GetDebugDevice()
		{
			return m_pd3dDebug;
		}

	private:
		ID3D11Debug*			m_pd3dDebug;
		ID3D11InfoQueue*	m_pd3dDebugQueue;

		D3D11_MESSAGE_ID	m_arrBreakOnIDsList[MAX_NUM_DEBUG_MSG_IDS];
		UINT							m_nNumCurrBreakOnIDs;

		UINT ParseIDs(const char * strMsgIDList, D3D11_MESSAGE_ID arrMsgList[MAX_NUM_DEBUG_MSG_IDS]) const;
	};

#else

	class CD3DDebug
	{
	public:
		bool Init(D3DDevice * pD3DDevice) { return false; }
		void Release() {}
		void Update(ESeverityCombination muteSeverity, const char * strMuteMsgList, const char * strBreakOnMsgList)  {}
	};

#endif // DIRECT3D10 && !PS3

#endif // __D3DDEBUG__H__
